package com.eastedu.controller;

import com.eastedu.domain.ObjectValueModel;
import com.eastedu.model.RequestParameter;
import com.eastedu.superise.handler.assignmen.AssignmentApplyUserIdHistoricalDataHandler;
import com.eastedu.superise.handler.assignmen.AssignmentTextOrderHistoricalDataHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 袁松明
 */
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api/v1/assignment/data-update")
public class AssignmentDataUpdateController {


    private final AssignmentApplyUserIdHistoricalDataHandler applyUserIdHistoricalDataHandler;
    private final AssignmentTextOrderHistoricalDataHandler assignmentTextOrderHistoricalDataHandler;


    /**
     * 更新应用者
     * 将历史应用者的id 更新为新的应用者
     * @param parameter RequestParameter
     * @return ObjectValueModel
     */
    @PostMapping("/apply-user-id")
    public HttpEntity<ObjectValueModel<Boolean>> updateApplyUserId(RequestParameter parameter) {
        applyUserIdHistoricalDataHandler.handle(parameter);
        return ResponseEntity.ok(new ObjectValueModel<>(Boolean.TRUE));
    }

    /**
     * 更新拉通排序
     * 将历史建设中心创建的题单 转为拉通排序规则
     * @param parameter RequestParameter
     * @return ObjectValueModel
     */
    @PostMapping("/text-order")
    public HttpEntity<ObjectValueModel<Boolean>> updateTextOrder(RequestParameter parameter) {
        assignmentTextOrderHistoricalDataHandler.handle(parameter);
        return ResponseEntity.ok(new ObjectValueModel<>(Boolean.TRUE));
    }
}
